#!/bin/bash

# 打印logo和描述信息
logo=$(cat <<'EOF'
 _____ _____          __    _____  _____   ____   _____
|_   _|  __ \        / /   |  __ \|  __ \ / __ \ / ____|
  | | | |__) |_   __/ /_   | |  | | |  | | |  | | (___                            | | |  ___/\ \ / / '_ \  | |  | | |  | | |  | |\___ \
 _| |_| |     \ V /| (_) | | |__| | |__| | |__| |____) |
|_____|_|      \_/  \___/  |_____/|_____/ \____/|_____/
                                                                                
         _   _             _
    /\  | | | |           | |                                                      /  \ | |_| |_ __ _  ___| | __
  / /\ \| __| __/ _` |/ __| |/ /
 / ____ \ |_| || (_| | (__|   <
/_/    \_\__|\__\__,_|\___|_|\_\
EOF
)
echo -e "$logo"
echo -e "\033[1;32;40m[*]IPv6 DDoS attacks refer to the exploitation of vulnerabilities or misconfigurations in the IPv6 protocol, launching attacks on target networks or servers with a large amount of malicious traffic to exhaust their bandwidth, system resources, or service capabilities, thereby preventing them from providing normal services or causing network disruptions.\033[1;37;40m"

# Define file dictionary
declare -A files
files=(
        ["1"]="ddos/ipv6_attack/ICMPv6_Flood.py"
        ["2"]="ddos/ipv6_attack/IPv6_Replay_Attack.py"
        ["3"]="ddos/ipv6_attack/IPv6_Flood_Attack.py"
        ["4"]="ddos/ipv6_attack/IPv6_SLAAC_Flood.py"
        ["5"]="ddos/ipv6_attack/IPv6_Fragmentation_Attack.py"
        ["6"]="ddos/ipv6_attack/Neighbor_Cache_Exhaustion.py"
        ["7"]="ddos/ipv6_attack/IPv6_ND.py"
)

# Create a menu using whiptail
while true; do
        choice=$(whiptail --title "IPv6 DDoS Attack Types" --menu "IPv6 DDoS attacks refer to the exploitation of vulnerabilities or misconfigurations in the IPv6 protocol, launching attacks on target networks or servers with a large amount of malicious traffic to exhaust their bandwidth, system resources, or service capabilities, thereby preventing them from providing normal services or causing network disruptions.\n\nPlease select an attack type:" 35 78 20 \
        "1" "IPv6 ICMPv6 Flood Attack" \
        "2" "IPv6 Replay Attack" \
        "3" "IPv6 Flood" \
        "4" "IPv6 SLAAC Flood Attack" \
        "5" "IPv6 Fragmentation Attack" \
        "6" "IPv6 Neighbor Cache Exhaustion Attack" \
        "7" "IPv6 Neighbor Discovery Protocol Attack" \
        "0" "Back" \
        3>&1 1>&2 2>&3)

        if [[ $? -eq 0 ]]; then
            if [[ "$choice" == "0" ]]; then
                echo "Operation cancelled."
                break
            else
                python3 "${files[$choice]}"
                break
            fi
        else
            echo "Operation cancelled."
            break
        fi
done
